#include "FileOperation.h"
#include <iostream>
FileOperation::FileOperation(std::string fileName) : fileName(fileName) { }

/// <returns>Contents of the file as specified in the constructor</returns>
std::string FileOperation::getContents() {
	return this->contents;
}

void FileOperation::loadContentsFromFile() {
	std::fstream file(this->fileName.c_str());
	if (!file.good()) {
		throw ExceptionFileDoesNotExist();
	}
	file.seekg(0, std::ios::end);
	size_t fileSize = file.tellg();
	this->contents = std::string(fileSize, ' ');
	file.seekg(0, std::ios::beg);
	file.read(&this->contents[0], fileSize);
	file.close();

}